# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
demo12_eig2.py
"""
import scipy.misc as sm
import numpy as np
import matplotlib.pyplot as mp

# True：提取绘图图片
original = sm.imread('../da_data/lily.jpg', True)
print(original.shape)

# 提取特征值
original = np.mat(original)
eigvals, eigvecs = np.linalg.eig(original)
# 抹掉一部分特征值，生成新图片
eigvals[50:] = 0
dst = eigvecs * np.diag(eigvals) * eigvecs.I

mp.subplot(121)
mp.imshow(original, cmap='gray')
mp.xticks([])
mp.yticks([])
mp.tight_layout()

mp.subplot(122)
mp.imshow(dst.real, cmap='gray')
mp.xticks([])
mp.yticks([])
mp.tight_layout()

mp.show()
